package cn.lzk._03_oneway;


import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;

public class Producer {
    public static void main(String[] args) throws Exception {
        //创建生产者
        DefaultMQProducer producer = new DefaultMQProducer("oneway_producer");
        //设置nameserver地址
        producer.setNamesrvAddr("localhost:9876");
        //启动
        producer.start();
        //创建消息体
        Message message = new Message("oneway", "hello", "这是一个单向消息，不会管发送成功或者失败".getBytes(StandardCharsets.UTF_8));
        //发送单向消息
        producer.sendOneway(message);
        //关闭
        producer.shutdown();
    }
}
